<template>
	<view>
		<view class="top-bar" @click="switchtabcur()">
			<view :class="'top-bar-item ' + (tabtopcur==0?'active':'')">
					<view class="text">签到次数</view>
					<view  class="bottom-line"></view>
			</view>
			<view :class="'top-bar-item ' + (tabtopcur==1?'active':'')">
					<view class="text">开户人数</view>
					<view  class="bottom-line"></view>
			</view>
		</view>
		<view class="radio-time-box">
			<view class="timer-box">
				<picker mode="date" :value="date" @change="bindDateChange">
					<view class="timer-text">
						{{date}}
					</view>
				      <!-- <view class="uni-input"></view> -->
				</picker>
			
				<view class="arrow-img">
					<image src="/static/images/bottom.png"></image>
				</view>
			</view>
		</view>
		<view class="shishi-box" > 
			<view class="content-box-content"  >
				<view class="content-box-content-item" v-for="(item,index) in signinlist">
					<view class="left-img-box">
						<view class="num-text">{{index+1}}</view>
						<view class="img-box">
							<image :src="item.userInfo.avatarUrl?'item.userInfo.avatarUrl':'/static/images/header.png'"></image>
						</view>
						<view class="infor-box">
							<view class="name">{{item.userInfo.nickName}}</view>
						<!-- 	<view class="patrmeng">市场部</view> -->
						</view>
					</view>
					<view class="right-sign" v-if="tabtopcur==0">
						签到  <text>{{item.num}}</text>次
					</view>
					<view class="right-sign " v-if="tabtopcur==1">
						开户  <text>{{item.num}}</text>人
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>


	const util = require("../../utils/util.js");
	//获取应用实例
	const api = require("../../config/api.js");
	export default {
		data() {
			return {
				tabtopcur: 0,
				date: '',
				signinlist :'',
				deptId:''
			}
		},
		components: {
			
		},
		filters: {
			
		},
		onLoad(option) {
			var _that = this;
			if(option&&option.deptId){
				this.deptId = option.deptId
			}
			console.log('option',)
			this.getDate({
			   format: true
		   })
		   
			
		},
		methods: {
			bindDateChange: function(e) {
				this.signinlist='';
			           this.date = e.target.value;
					    this.managerClassifyStatistics();	
						
			       },
			managerClassifyStatistics(){
				var that = this;
				var data = new Object();
				if(this.tabtopcur==0){
					data.classify = 1;
				}else{
					data.classify = 2;
					
					
					
				}
				data.day = this.date;
				data.hasNum = '';
				data.deptId = this.deptId;
				util.request(api.managerClassifyStatistics , data, "POST").then(res => {
						 console.log("分类返回",res);
						if(res.error==0){
							
							this.signinlist = res.data;
						}
				})
				
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
	
				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				
				  this.date = `${year}-${month}-${day}`;
				  // 获取时间以后执行日经理日统计接口
				  this.managerClassifyStatistics();			
			},
			switchtabcur(){
					this.signinlist='';
				if(this.tabtopcur==0){
					this.tabtopcur=1;
				
				
				}else{
					this.tabtopcur=0
				}
				// 获取时间以后执行日经理日统计接口
				this.managerClassifyStatistics();		
			}
			
		}
	}
</script>

<style>
	@import url("./classifyCalc.css");
</style>
